package com.recruit.g1.common.pager;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.List;

@ApiModel("分页数据模型")
public class PageResult<T> extends com.recruit.g1.common.pager.BasePageQuery {
    @ApiModelProperty("总行数")
    protected Long total;
    @ApiModelProperty("分页数据")
    protected List<T> objects;

    public PageResult() {
    }

    public PageResult(BasePageQuery simplePager) {
        if (simplePager == null) {
            this.pageNo = 1;
        } else {
            this.pageNo = simplePager.getPageNo();
            this.pageSize = simplePager.getPageSize();
        }
    }

    public PageResult(Integer pageSize, Integer currentPageIndex) {
        super(pageSize, currentPageIndex);
    }

    public Long getTotal() {
        return this.total;
    }

    public void setTotal(Long total) {
        this.total = total;
    }

    public List<T> getObjects() {
        return this.objects;
    }

    public void setObjects(List<T> objects) {
        this.objects = objects;
    }

    public Integer getTotalPage() {
        return (int)Math.ceil((double)this.total / (double)this.pageSize);
    }
}
